﻿//随机生成100个0~1000间的整数
//使用LINQ语句对这些整数从大到小排列
//并求和与平均数

Random random = new Random();
List<int> intlist = new List<int>();
for (int i = 0; i < 100; i++)
{
    intlist.Add(random.Next(1000));
}
Console.WriteLine("该随机数列为：");
for (int i = 0; i < 100; i++)
{
    Console.Write(intlist[i]+" ");
}

List<int> orderList = new List<int>();
foreach (int i in intlist.OrderBy(n => n))
    orderList.Add(i);

Console.WriteLine("\n\n排序后的随机数列为：");
for (int i = 0; i < 100; i++)
{
    Console.Write(orderList[i] + " ");
}


int sum = orderList.Sum();
Console.WriteLine("\n随机数和为："+sum);
double Average = sum *1.0 / orderList.Count();
Console.WriteLine("\n随机数平均值为：" + Average);

